package tech.aistar.mapper.trading;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tech.aistar.entity.trading.TransactionMessage;
import java.util.List;

/**
 * @author Ace
 * @version 1.0
 * @descriiption:本类用来演示:二手交易留言表接口
 * @date 2019/9/27 0027.
 */
public interface TransactionMessageMapper {
    /**
     * 查--查所有
     */
    @Select("select*from transaction_message")
    List<TransactionMessage> findAll();

    /**
     *查--根据id查
     */
    @Select("select*from transaction_message where id=#{value}")
    TransactionMessage findById(Integer id);

    /**
     *改--修改更新属性
     */
    @Update("update transaction_message set goods_id=#{goodsId},goods_name=#{goodsName},leave_name=#{leaveName}," +
            "content=#{content},date=#{date},avatar_images=#{avatarImages},praise=#{praise}")
    void update(TransactionMessage transactionMessage);

    /**
     * 删----通过设置status的值达到删除某个数据,不用真的删除
     * @param id
     */
    @Update("update transaction_message set status=1 where id=#{value}")
    void delById(Integer id);

    /**
     * 添加 二手交易留言
     */
    @Insert("insert into transaction_message(goods_id,goods_name,leave_name,content,date,avatar_images,praise)" +
            "values(#{goodsId},#{goodsName},#{leaveName},#{content},#{date},#{avatarImages},#{praise})")
    void save(TransactionMessage transactionMessage);
}
